<template>
	<view class="open-vip">
		<!-- S 顶部导航 -->
		<sol-navbar title="开通会员"></sol-navbar>
		<!-- E 顶部导航 -->

		<!-- S 会员卡 -->
		<view class="open-vip_card">
			<view class="card-left">
				<text class="card-left_name line-1">花轮先生花轮先生花轮先生花轮先生</text>
				<view class="card-left_banner">
					<text class="card-left_banner__vip">VIP</text>
					<text class="card-left_banner__text line-1">未开通会员</text>
				</view>
				<text class="card-left_price line-1">15元/单月开通</text>
			</view>
			<view class="card-right">
				<image class="card-right_brand" src="https://dummyimage.com/200x200" mode="scaleToFill"></image>
				<button class="card-right_btn" @click="fnOpenClick('open')">开通</button>
			</view>
		</view>
		<!-- E 会员卡 -->

		<!-- S 标签文字 -->
		<view class="open-vip_label">可拥有的会员特权</view>
		<!-- E 标签文字 -->

		<!-- S 会员特权列表 -->
		<view class="open-vip_list">
			<view class="privilege" v-for="item in privilegeList" :key="item.id">
				<image class="privilege-icon" :src="item.icon" mode="scaleToFill"></image>
				<text class="privilege-name line-1" v-text="item.name">名称</text>
				<text class="privilege-explain" v-text="item.explain">内容</text>
			</view>
		</view>
		<!-- E 会员特权列表 -->

		<!-- S 弹出套餐选择 -->
		<sol-drawer v-model="drawer.open" title="套餐选择" primary-text="确认开通" cancel-text="取消" @click="fnOpenClick">
			<template v-slot:default>
				<view class="open-vip_meal" v-for="meal in setMealList" :key="meal.id"
					:class="{'open-vip_meal-select': meal.id == drawer.selectId }"
					@click="fnOpenClick('select', meal.id)">
					<text class="meal_name line-1" v-text="meal.name">套餐名</text>
					<text class="meal_discount" v-if="meal.discountRate < 1">
						{{(meal.discountRate * 10) || 0}}折省{{meal.discountProvince || 0}}元
					</text>
					<view class="meal_price">
						<text v-text="meal.discountPrice">折扣价</text>
						<text class="meal_price-unit" v-text="meal.unitType">单位类型</text>
					</view>
				</view>
			</template>
		</sol-drawer>
		<!-- E 弹出套餐选择 -->

		<button class="open-vip__btn" @click="fnOpenClick('open')">立即开通</button>
		<view class="safe-area-inset-bottom" style="height: 96rpx;"></view>
	</view>
</template>

<script>
	export default {
		name: "OpenVip",
		data() {
			return {
				// 特权列表
				privilegeList: [{
						id: 112,
						icon: "/static/icon-privilege/icon_abyss.png",
						name: "体验深渊模式",
						explain: "牵引内容格式特权变动，可浏览前3小时的内容以及后时间段6小时内的内容。",
					},
					{
						id: 122,
						icon: "/static/icon-privilege/icon_release.png",
						name: "增加发表次数",
						explain: "从基础上每天可额外增加3次发布次数",
					},
					{
						id: 113,
						icon: "/static/icon-privilege/icon_chat.png",
						name: "可创建群聊",
						explain: "可以创建带有话题性质或粉丝性质的群聊",
					},
					{
						id: 114,
						icon: "/static/icon-privilege/icon_fragment.png",
						name: "获赠碎片",
						explain: "开通会员随机最高获赠10块碎片",
					},
					{
						id: 115,
						icon: "/static/icon-privilege/icon_user.png",
						name: "发现更多用户",
						explain: "可以浏览到更多用户以及发起聊天",
					},
					{
						id: 116,
						icon: "/static/icon-privilege/icon_expect.png",
						name: "敬请期待",
						explain: "",
					},
				],
				// 套餐列表
				setMealList: [{
						id: 10,
						name: '单月会员',
						unit: '元',
						unitType: '元/月',
						originalPrice: '15',
						discountPrice: '15',
						discountRate: '1',
						discountProvince: '0'
					},
					{
						id: 11,
						name: '季度会员',
						unit: '元',
						unitType: '元/季',
						originalPrice: '36',
						discountPrice: '29',
						discountRate: '0.8',
						discountProvince: '7'
					},
					{
						id: 12,
						name: '年度会员',
						unit: '元',
						unitType: '元/年',
						originalPrice: '108', // 原价
						discountPrice: '65', // 折扣价
						discountRate: '0.6', // 折扣率
						discountProvince: '43', // 折扣省
					}
				],
				// 套餐选择弹出
				drawer: {
					// 弹出
					open: false,
					// 选中ID
					selectId: 0,
				}
			};
		},
		computed: {},
		methods: {
			// 弹出点击
			fnOpenClick(type = '', value = 0) {
				this.$log('fnOpenClick=>', type, value);
				switch (type) {
					case 'open': // 弹出
						this.drawer = {
							// 弹出
							open: true,
							// 选中ID
							selectId: 10,
						}
						break;
					case 'select': // 套餐选择
						this.drawer.selectId = value;
						break;
					case 'primary':
						break;
					case 'mask':
					case 'cancel':
						this.drawer = {
							open: false,
							selectId: null,
						}
						break;
				}
			}
		}
	}
</script>

<style lang="scss">
	.open-vip {
		min-height: 100vh;
		background-color: $--color-background;

		// 会员卡
		&_card {
			display: flex;
			flex-direction: row;
			justify-content: space-between;
			padding: 48rpx 32rpx;
			margin: 36rpx 28rpx;
			border-radius: 18rpx;
			background-color: $--color-block;

			.card-left {
				flex: 1;

				&_name {
					width: 420rpx;
					font-size: 48rpx;
					font-family: PingFang SC;
					font-weight: bold;
					color: #DDDDDD;
					display: block;
				}

				&_banner {
					display: flex;
					align-items: center;
					width: 300rpx;
					background-image: linear-gradient(to right, rgb(77, 89, 98) 0%, rgb(71, 78, 84) 100%);
					border-radius: 8rpx;
					padding: 15rpx 20rpx;
					margin-top: 24rpx;
					margin-bottom: 24rpx;

					&__vip {
						font-size: 28rpx;
						font-family: PingFang SC;
						font-weight: bold;
						font-style: italic;
						color: #707478;
					}

					&__text {
						width: 200rpx;
						font-size: 28rpx;
						font-family: PingFang SC;
						font-weight: 400;
						color: #848585;
						display: block;
						margin-left: 20rpx;
					}
				}

				&_price {
					font-size: 28rpx;
					font-family: PingFang SC;
					font-weight: 400;
					color: #BBBBBB;
				}
			}

			.card-right {
				&_brand {
					width: 148rpx;
					height: 148rpx;
					display: block;
					background-color: #474e54;
					border-radius: 50%;
				}

				&_btn {
					width: 128rpx;
					height: 64rpx;
					line-height: 64rpx;
					border-radius: 64rpx;
					border: none;
					overflow: hidden;
					padding: 0;
					font-size: 32rpx;
					font-weight: 700;
					letter-spacing: 4rpx;
					background-color: #f2bf2f !important;
					color: #69645a !important;
					margin-top: 24rpx;
				}
			}
		}

		// 标签文字
		&_label {
			padding: 28rpx;
			font-size: 32rpx;
			font-weight: 400;
			color: #DDDDDD;
		}

		// 特权列表
		&_list {
			column-count: 2;
			column-gap: 28rpx;
			padding: 28rpx;
			margin-bottom: 28rpx;

			.privilege {
				background-color: #474e54;
				break-inside: avoid;
				box-sizing: border-box;
				padding: 32rpx 28rpx;
				border-radius: 18rpx;
				margin-bottom: 28rpx;
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;

				&-icon {
					height: 112rpx;
					width: 128rpx;
					display: block;
					overflow: hidden;
				}

				&-name {
					width: 100%;
					font-size: 32rpx;
					font-weight: bold;
					text-align: center;
					color: #DDDDDD;
					letter-spacing: 4rpx;
					margin-top: 32rpx;
				}

				&-explain {
					font-size: 28rpx;
					font-weight: 400;
					color: #878787;
					letter-spacing: 4rpx;
					margin-top: 24rpx;
				}
			}
		}

		// 套餐列表
		&_meal {
			display: flex;
			flex-direction: row;
			align-items: baseline;
			justify-content: flex-end;
			padding: 28rpx;
			color: #BBBBBB;
			font-size: 32rpx;
			font-weight: 400;
			margin-bottom: 20rpx;

			&-select {
				color: #DDDDDD;
				background-color: #607d8b;
				border-radius: 18rpx;
			}

			.meal {
				&_name {
					display: block;
					flex-grow: 1;
					font-size: 36rpx;
					font-weight: 400;
					width: 40%;
				}

				&_discount {
					background-color: #645e45;
					font-size: 24rpx;
					font-weight: 400;
					color: #f2bf2f;
					display: block;
					border-radius: 12rpx;
					padding: 2rpx 12rpx;
					margin-right: 24rpx;
				}

				&_price {
					font-size: 36rpx;
					font-weight: bold;

					&-unit {
						font-size: 32rpx;
						font-weight: 400;
						margin-left: 12rpx;
					}
				}
			}
		}

		&__btn {
			width: 424rpx;
			height: 94rpx;
			line-height: 94rpx;
			border-radius: 94rpx;
			border: none;
			overflow: hidden;
			padding: 0;
			font-size: 32rpx;
			font-weight: normal;
			letter-spacing: 4rpx;
			background-color: #607d8b !important;
			color: #DDDDDD !important;
		}
	}
</style>
